log.info('cpu usage is high (not profiling yet: %s/%s): %s', self.count, NUM_CONSECUTIVE_HIGHS, user + kernel)
if self.count > NUM_CONSECUTIVE_HIGHS:
import wx as wx
wx.CallAfter(self.prompt_for_profiling)
else:
self.count = 0
def profiling_usage(self, user, kernel):
self.user = user
self.kernel = kernel
if user + kernel >= self.threshold:
log.info('cpu usage is high: %s' % (user + kernel))
self.stack_info.append(get_stack_info())
self.count += 1
if self.count > PROFILE_TICKS:
self.disable()
self.send_info()
else:
log.info('cpu usage was low again: %s' % (user + kernel))
log.info('')
self.count = 0
self.state = 'watching'
def disabled_usage(self, user, kernel):
pass
def send_info(self):
log.info('sending diagnostic information...')
Diagnostic = Diagnostic
import util.diagnostic
import wx
try:
d = Diagnostic(description = 'CPU usage was too high.')
d.prepare_data()
if d.do_no_thread_post():
return wx.CallAfter(wx.MessageBox, _('A log of the problem has been sent to digsby.com.\n\nThanks for helping!'), _('Diagnostic Log'))
except Exception:
print_exc()
wx.CallAfter(wx.MessageBox, _('There was an error when submitting the diagnostic log.'))
def prompt_for_profiling(self):
if self._CPUWatch__in:
return None
self._CPUWatch__in = True
log.info('prompting for profiling info')
dev = getattr(sys, 'DEV', False)
if profilers_enabled():
self.state = 'profiling'
return log.info('profiler is already enabled')
import wx
if dev or wx.YES == wx.MessageBox(_('Digsby appears to be running slowly.\n\nDo you want to capture diagnostic information and\nsend it to digsby.com?'), _('Digsby CPU Usage'), style = wx.YES_NO | wx.ICON_ERROR):